﻿



--新建员工档案
CREATE proc [dbo].[proc_Employee_Create]
(
	@UserName nvarchar(50),
	@EName nvarchar(20),
	@Enumber nvarchar(20),
	@ETempNumber nvarchar(20),
	@Sex nvarchar(10),
	@Birthday nvarchar(20),
	--@HomePhone nvarchar(30),
	@MobilePhone nvarchar(30),
	@Email nvarchar(50),
	@IDcard nvarchar(30),
	@Address nvarchar(200),
	@Education nvarchar (30),
	@HeadPic nvarchar(50),
	@WorkYM nvarchar(50),
	@Marriage nvarchar(50),
	@PoliticsStatus nvarchar(50),
	@Cuenta nvarchar(50),
	@UpName nvarchar(20),
	@IsInsured INT,
	@Pid int,
	@CompanyId INT,
	@Cid INT,
	
	@OldEName NVARCHAR(50),
	@Nation NVARCHAR(20),
	@ShenGao INT,
	@BloodType NVARCHAR(10),
	@YXZY NVARCHAR(50),
	@SkillName NVARCHAR(50),
	@NativeP NVARCHAR(50),
	@QQ NVARCHAR(50),
	@ForeignL NVARCHAR(50),
	@DirveType NVARCHAR(50),
	@Hobby NVARCHAR(50)
	
)
as
--	declare @CompanyId int
IF(@CompanyId=0)
	set @CompanyId = (Select companyid from aspnet_Users where username = @UpName )		
	
	insert into Employee
			   (
				UserName,
				EName,
				Enumber,
				ETempNumber,
				Sex,
				Birthday,
				MobilePhone,
				Email,
				IDcard,
				Address,
				Education,
				WorkYM,
				Marriage,
				PoliticsStatus,
				Cuenta,
				HeadPic,
				UpName,
				UpTime,
				IsInsured,
				Pid,
				Cid,
				OldEName,
				Nation,
				ShenGao,
				BloodType,
				YXZY,
				SkillName,
				NativePlace,
				QQ,
				ForeignLanguage,
				DriveType,
				Hobby,
				CompanyId
                           )
			   values
                    	  (
				@UserName,
				@EName,
				@Enumber,
				@ETempNumber,
				@Sex,
				@Birthday,
				@MobilePhone,
				@Email,
				@IDcard,
				@Address,
				@Education,
				@WorkYM,
				@Marriage,
				@PoliticsStatus,
				@Cuenta,
				@HeadPic,
				@UpName,
				getdate(),
				@IsInsured,
				@Pid,
				@Cid,
				@OldEName,
				@Nation,
				@ShenGao,
				@BloodType,
				@YXZY,
				@SkillName,
				@NativeP,
				@QQ,
				@ForeignL,
				@DirveType,
				@Hobby,
				@CompanyId
                           )
	
	declare @EId int 
	set @EId = (select top 1 id from Employee order by id desc )
	--创建入职申请数据
	insert into Employee_Entry(EId) values(@EId)
	--创建离职申请数据 
	insert into Employee_Dimission(EId) values(@EId)



